package com.solocredit.finance.utils.helper

import com.solocredit.finance.base.utils.SPUtils
import com.solocredit.finance.config.MullaConfigs

/**
 * MullaFlow
 * @Author wwdeng
 * @CreateTime: 2024/7/24 13:47
 * @Annotation：SharedPreferences 数据存取帮助类
 */
object SharedHelper {

    /**
     * SharedPreferences 保存 KEY
     */
    object MULLA_SPKEY{

        /**
         * App 转发时区id Key
         */
        const val MULLA_TIMEZONE_ID = "${MullaConfigs.MULLA_APPNAME}_TimeZone_Id"
        /**
         * App 转发时区 Key
         */
        const val MULLA_TIMEZONE = "${MullaConfigs.MULLA_APPNAME}_TimeZone"
        /**
         * App 转发时区 区号  Key
         */
        const val MULLA_TIMEZONE_CODE = "${MullaConfigs.MULLA_APPNAME}_TimeZone_Code"
        /**
         * App 转发时区 国家标识  Key
         */
        const val MULLA_TIMEZONE_COUNTRY = "${MullaConfigs.MULLA_APPNAME}_TimeZone_Country"

        /**
         * 业务APP 配置请求
         */
        const val MULLA_COMMON = "${MullaConfigs.MULLA_APPNAME}_Common"

        /**
         * 用户登录状态
         */
        const val MULLA_LOGIN = "${MullaConfigs.MULLA_APPNAME}_isLogin"

        /**
         * 用户id（userId）
         * 登录接口获取 VH7vqSZFdCIj0qGuSRAZw
         */
        const val MULLA_USERID = "${MullaConfigs.MULLA_APPNAME}_UserId"

        /**
         * 用户Token
         * 登录接口获取 VH7vqSZFdCIj0qGuSRAZw
         */
        const val MULLA_TOKEN = "${MullaConfigs.MULLA_APPNAME}_Token"

        /**
         * 用户号码
         * 登录页面获取
         */
        const val MULLA_MOBILE = "${MullaConfigs.MULLA_APPNAME}_Mobile"

        /**
         * 是否是渠道用户
         * 登录接口获取
         */
        const val MULLA_IS_ADSOURCE = "${MullaConfigs.MULLA_APPNAME}_isAdSource"

        /**
         * 是否是审核账号
         * 登录时保存
         */
        const val MULLA_IS_CONFIG_ACCOUNT = "${MullaConfigs.MULLA_APPNAME}_isConfigAccount"

        /**
         * 用户流程状态
         */
        const val MULLA_PROCESS = "${MullaConfigs.MULLA_APPNAME}_Process"

        /**
         * 用户签到信息
         */
        const val MULLA_SIGN_INFO = "${MullaConfigs.MULLA_APPNAME}_Sign_Info"

        /**
         * 用户VIP等级
         * 1    个产品 VIP1
         * 2-4  个产品 VIP2
         * > 4  个产品 VIP3
         */
        const val MULLA_VIP = "${MullaConfigs.MULLA_APPNAME}_Vip"

        /**
         * 自定义数据
         */
        const val MULLA_CUSTOM_DATA = "${MullaConfigs.MULLA_APPNAME}_Custom_Data"

        /**
         * 用户优惠券信息
         */
        const val MULLA_USER_COUPON_INFO = "${MullaConfigs.MULLA_APPNAME}_Coupon_Info"

        /**
         * 产品列表
         */
        const val MULLA_PRODCTS = "${MullaConfigs.MULLA_APPNAME}_Product_Info"

        /**
         * Active Dialog Show Num
         */
        const val MULLA_DIALOG_ACTIVE_NUM = "${MullaConfigs.MULLA_APPNAME}_Dialog_Active_Num"

        /**
         * Normal Dialog Show Num
         */
        const val MULLA_DIALOG_NORMAL_NUM = "${MullaConfigs.MULLA_APPNAME}_Dialog_Normal_Num"

        /**
         * 选择语言类型
         */
        const val MULLA_LANGUAGE_SELECTED_TYPE = "${MullaConfigs.MULLA_APPNAME}_Language_Selected_Type"

        /**
         * Notice Dialog Show Num
         */
        const val MULLA_DIALOG_NOTICE_NUM = "${MullaConfigs.MULLA_APPNAME}_Dialog_Notice_Num"

        /**
         * 启动页权限是否显示
         */
        const val MULLA_PERMISSION_LAUNCH_SHOW = "${MullaConfigs.MULLA_APPNAME}_Permission_Launch_Show"

        /**
         * 权限列表是否同意：0未操作  1已同意  -1拒绝
         */
        const val MULLA_PERMISSION_LIST_STATUS = "${MullaConfigs.MULLA_APPNAME}_Permission_List_Status"

        /**
         * 上一次非强制更新提示时间戳
         */
        const val MULLA_VERSION_UPDATE_LAST_TIME = "${MullaConfigs.MULLA_APPNAME}VersionUpdateLastTime"
    }

    /**
     * 保存数据
     */
    fun saveMullaSPData(key: String,value: Any?){
        SPUtils.put(key,value)
    }

    /**
     * 获取String
     */
    fun getMullaSPString(key: String): String{
        return SPUtils.getString(key)
    }

    /**
     * 获取boolean
     */
    fun getMullaSPBoolean(key: String): Boolean{
        return SPUtils.getBoolean(key,false)
    }

    /**
     * 获取Int
     */
    fun getMullaSPInt(key: String): Int{
        return SPUtils.getInt(key,0)
    }

    /**
     * 移除指定内容
     */
    fun removeMullaData(key: String){
        SPUtils.remove(key)
    }

    /**
     * 退出登录，移除用户信息
     */
    fun onMullaLoginOut(){
        //移除已登录状态
        removeMullaData(MULLA_SPKEY.MULLA_LOGIN)
        //移除用户Token
        removeMullaData(MULLA_SPKEY.MULLA_TOKEN)
        //移除用户id
        removeMullaData(MULLA_SPKEY.MULLA_USERID)
        removeMullaData(MULLA_SPKEY.MULLA_MOBILE)
        removeMullaData(MULLA_SPKEY.MULLA_IS_ADSOURCE)
        removeMullaData(MULLA_SPKEY.MULLA_IS_CONFIG_ACCOUNT)
        removeMullaData(MULLA_SPKEY.MULLA_PROCESS)
        removeMullaData(MULLA_SPKEY.MULLA_SIGN_INFO)
        removeMullaData(MULLA_SPKEY.MULLA_VIP)
        removeMullaData(MULLA_SPKEY.MULLA_CUSTOM_DATA)
        removeMullaData(MULLA_SPKEY.MULLA_USER_COUPON_INFO)
        removeMullaData(MULLA_SPKEY.MULLA_PRODCTS)
        removeMullaData(MULLA_SPKEY.MULLA_PERMISSION_LIST_STATUS)
//        removeMullaData(MULLA_SPKEY.MULLA_LANGUAGE_SELECTED_TYPE)
    }
}